<?php

//提现管理

namespace app\admin\controller;
use app\common\BaseHelper;
use app\admin\model\User;
use app\common\model\Ordercommission;
use app\common\model\Usercommission;

use think\Request;

class Postal extends Base{

    public function index() {
        return $this->fetch();
    }

    public function indexApi() {
        $request = Request::instance();
        $param = $request->param();
        $where = ['a.tenantId'=>session('TENANT_ID'),'type'=>'1'];

        $start = $param['start'];
        $length = $param['length'];

        if($param['search']['value']) {  //拼接搜索条件
            $ss = json_decode($param['search']['value'],true);
            if($ss['status']) {
                $where['a.status'] = $ss['status'];
            } else {
                $where = '';
            }
        }

        $list = Usercommission::alias('a')->join('user b','a.userId=b.id')->field('a.*,b.mobile,b.nickName')->where($where)->select();       

        $count = Usercommission::alias('a')->where($where)->count();
        $res = [
            'status' => '1',
            'draw' => $param['draw'],
            'data' => $list,
            'recordsFiltered' => $count,
            'recordsTotal' => $count,
        ];
        return json($res);
    }
}